home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-28 | 966 b | 55 lines | [TEXT/CWIE] |
- // Ear.h
-
- #ifndef Ear_h
- #define Ear_h
-
- #ifndef EarBase_h
- #include "EarBase.h"
- #endif
-
- template < class Head >
- class Ear: public EarBase
- {
- typedef Head HeadType;
- typedef void (HeadType::*Nerve)();
-
- private:
- Head& head;
- const Nerve announcement;
- const Nerve destruction;
-
- public:
- Ear( Head& theHead, Nerve announce, Nerve destroy = 0 )
- : EarBase(),
- head( theHead ),
- announcement( announce ),
- destruction( destroy )
- {
- Assert( announcement != 0 );
- }
-
- Ear( const Announcer& announcer, Head& theHead, Nerve announce, Nerve destroy = 0 )
- : EarBase( announcer ),
- head( theHead ),
- announcement( announce ),
- destruction( destroy )
- {
- Assert( announcement != 0 );
- }
-
- virtual void HearAnnouncement()
- {
- head.SetContext();
- (head.*announcement)();
- }
-
- virtual void HearDestruction()
- {
- head.SetContext();
- Assert( destruction != 0 );
- (head.*destruction)();
- }
- };
-
- #endif
-